package com.java.zhuiyun.api.jielongidiomlevel.controller;

import com.java.zhuiyun.annotation.OptLog;
import com.java.zhuiyun.api.jielongidiomlevel.entity.JieLongIdiomLevel;
import com.java.zhuiyun.api.jielongidiomlevel.model.JieLongIdiomLevelModel;
import com.java.zhuiyun.api.jielongidiomlevel.service.JieLongIdiomLevelService;
import com.java.zhuiyun.common.errorCode.CommonException;
import com.java.zhuiyun.common.response.CommonConstants;
import com.java.zhuiyun.common.response.CommonResult;
import com.java.zhuiyun.config.AuthAccess;
import com.java.zhuiyun.util.pageUtil.PageRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName JieLongIdiomLeveController
 * @Description TODO 成语接龙关卡管理接口 后台管理系统分页全查所有关卡、uni-app全查所有关卡、添加关卡、更新关卡信息
 * @Author 杨友朋
 * @Date 2023/9/13 9:14
 **/
@RestController
@RequestMapping("/JieLongIdiomLevel")
@Api(tags = "成语接龙关卡管理")
@Slf4j
public class JieLongIdiomLevelController {
    @Resource
    JieLongIdiomLevelService jieLongIdiomLevelService;

    /**
    * @Author 杨友朋
    * @Description TODO 后台管理系统分页全查所有关卡
    * @Date 2023/10/12 10:49
    * @Return CommonResult
    * @param pageRequest
    */
    @GetMapping("/selectLevel")
    @ApiOperation(value = "后台管理系统分页全查所有关卡")
    @OptLog(modular = "成语接龙关卡管理", type = CommonConstants.ADD, describe = "分页全查关卡")
    public CommonResult selectLevel(PageRequest pageRequest,Integer id){
        return CommonResult.ok(jieLongIdiomLevelService.selectLevel(pageRequest,id));
    }

    /**
    * @Author 杨友朋
    * @Description TODO uni-app全查所有关卡
    * @Date 2023/10/12 10:50
    * @Return CommonResult
    * @param
    */
    @GetMapping("/userSelectLevel")
    @AuthAccess
    @ApiOperation(value = "uni-app全查所有关卡")
    @OptLog(modular = "成语接龙关卡管理", type = CommonConstants.ADD, describe = "uni-app全查所有关卡")
    public CommonResult userSelectLevel(){
        return CommonResult.ok(jieLongIdiomLevelService.userSelectLevel());
    }
    /**
     * @Author 杨友朋
     * @Description TODO 添加关卡
     * @Date 2023/9/13 10:55
     * @Return CommonResult
     * @param jieLongIdiomLevel
     */
    @PostMapping("/insertLevel")
    @ApiOperation(value = "添加关卡")
    @OptLog(modular = "成语接龙关卡管理", type = CommonConstants.ADD, describe = "添加关卡")
    public CommonResult insertLevel(@RequestBody JieLongIdiomLevelModel jieLongIdiomLevel) throws CommonException {
        return jieLongIdiomLevelService.insertLevel(jieLongIdiomLevel);
    }

    /**
    * @Author 杨友朋
    * @Description TODO 更新关卡信息
    * @Date 2023/10/12 10:54
    * @Return CommonResult
    * @param jieLongIdiomLevel
    */
    @PostMapping("/updateLevel")
    @ApiOperation(value = "更新关卡信息")
    @OptLog(modular = "成语接龙关卡管理", type = CommonConstants.ADD, describe = "更新关卡信息")
    public CommonResult updateLevel(@RequestBody JieLongIdiomLevelModel jieLongIdiomLevel){
        return jieLongIdiomLevelService.updateLevel(jieLongIdiomLevel);
    }

}
